package besteAukera;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Toolkit;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

public class Hizkuntza2 extends JFrame {

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JPanel jPanel = null;
	private JButton euskeraz = null;
	private JButton erderaz = null;
	private JLabel euskerazLabel=null;
	private Hizkuntza2 hizkuntzaAukeratu=this;  //  @jve:decl-index=0:visual-constraint="10,106"

	/**
	 * This method initializes jPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private Fondoa getJPanel() {
		if (jPanel == null) {
			GridBagConstraints gridBagConstraints = new GridBagConstraints();
			gridBagConstraints.gridx = 0;
			gridBagConstraints.gridy = 0;
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
			gridBagConstraints1.gridx = 0;
			gridBagConstraints1.gridy = 1;
			GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
			gridBagConstraints2.gridx = 0;
			gridBagConstraints2.gridy = 2;
			
			jPanel = new Fondoa();
			jPanel.setLayout(new GridBagLayout());
			jPanel.add(getEuskerazLabel(),gridBagConstraints);
			jPanel.add(getEuskeraz(), gridBagConstraints1);
			jPanel.add(getErderaz(),gridBagConstraints2);
			
		}
		return (Fondoa) jPanel;
	}

	/**
	 * This method initializes Euskeraz	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getEuskeraz() {
		if (euskeraz == null) {
			euskeraz = new JButton("Sistema digitaletako simuladorea");
			euskeraz.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
				DatuMota eusk=new DatuMota("Euskeraz");
				eusk.setLocationRelativeTo(null);
				eusk.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			    eusk.setVisible(true);
			    hizkuntzaAukeratu.setVisible(false);
				}
			});
		}
		return euskeraz;
	}

	/**
	 * This method initializes Erderaz	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getErderaz() {
		if (erderaz == null) {
			erderaz = new JButton("  Simulador de sistemas digitales ");
			erderaz.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
					DatuMota erd=new DatuMota("Erderaz");
					erd.setLocationRelativeTo(null);
					erd.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				    erd.setVisible(true);
					hizkuntzaAukeratu.setVisible(false);
				}
			});
		}
		return erderaz;
	}
	private JLabel getEuskerazLabel() {
		if (euskerazLabel == null) {
			euskerazLabel = new JLabel("  ");
			
		}
		return euskerazLabel;
	}
	


	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				Toolkit tk=Toolkit.getDefaultToolkit();
				Dimension tamaina=tk.getScreenSize();
				UIManager.getDefaults().put("FileChooser.cancelButtonText","filechoser");
				if(tamaina.getWidth()<=800){
					 JLabel zabalera = new JLabel("Aplikazioak ez du ondo egiten 800x600eko tamainarekin eta itxi egingo da. Aldatu mesedez");
					 
					 
		              JLabel altuera = new JLabel("Esta aplicacion no funciona correctamente con una pantalla de 800x600 y se va a cerrar. Cambiala por favor");
		             
		              Object[] message = {zabalera.getText(), 
		                      altuera.getText()};
		            
		              JOptionPane pane = new JOptionPane( message, 
		                                              JOptionPane.WARNING_MESSAGE, 
		                                              JOptionPane.CLOSED_OPTION);
		              pane.putClientProperty("OptionPane.cancelButtonText","Ados/Aceptar");
		              pane.createDialog(null,"800x600").setVisible(true);
		      
		           
		              System.exit(0);
				}
				Hizkuntza2 thisClass = new Hizkuntza2();
				thisClass.setTitle("Hizkuntza / Idioma");
				thisClass.setLocationRelativeTo(null);
				thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				thisClass.setVisible(true);
		


			}
		});
	}

	/**
	 * This is the default constructor
	 */
	public Hizkuntza2() {
		super();
		initialize();
//		this.setResizable(false);
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
//		this.setSize(1000, 1000);
		this.setIconImage(Toolkit.getDefaultToolkit().getImage("irudiak/upv.gif"));
		this.setContentPane(getJContentPane());
		this.setTitle("JFrame");
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			hizkuntzaAukeratu.setSize(new Dimension(300, 200));
			jContentPane = new JPanel();
			jContentPane.setLayout(new BorderLayout());
			jContentPane.add(getJPanel(), BorderLayout.CENTER);
			
		}
		return jContentPane;
	}

}
